﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sealight.Core.DataAdapter;

namespace Sealight.Core.Domain
{
    public class NewsEntity
    {
        public virtual Guid NewsID { get; set; }

        public virtual string Title { get; set; }
        public virtual string ImageURL { get; set; }
        public virtual string Keyword { get; set; }
        public virtual int NumberView { get; set; }
        public virtual string Description { get; set; }
        public virtual string Detail { get; set; }
        public virtual bool IsActive { get; set; }
        public virtual DateTime CreatedDate { get; set; }
        public virtual DateTime UpdatedDate { get; set; }
        public virtual DateTime PublishedDate { get; set; }

        public virtual LanguageEntity Language { get; set; }
        public virtual NewsCategoryEntity NewsCategory { get; set; }
        public virtual NewsSourceEntity NewsSource { get; set; }

        public virtual news ToDataAdapter()
        {
            news entity = new news
            {
                id = this.NewsID,
                title = this.Title,
                image_url = this.ImageURL,
                keyword = this.Keyword,
                number_view = this.NumberView,
                description = this.Description,
                detail = this.Detail,
                is_active = this.IsActive,
                created_date = this.CreatedDate,
                updated_date = this.UpdatedDate,
                published_date = this.PublishedDate,               
                category =this.NewsCategory!= null ? this.NewsCategory.ToDataAdapter():null,
                source = this.NewsSource !=null ? this.NewsSource.ToDataAdapter():null
            };

            if (this.Language != null)
            {
                entity.language = this.Language.ToDataAdapter();
            }

            return entity;
        }
    }
}
